package com.colorlight.cloud.emqx;

import okhttp3.*;

import java.io.IOException;

public class EMQXNodesAPIExample {
	public static void main(String[] args) {
		// 删除一个链接 : /clients/{clientID}   clientID需要转义  这里需要注意 删除ClientID 需要加入时间戳 这个需要先查出来
		//或者在连接时 加入redis （更新）
		// 根据 emqx查询 clients?page=1&limit=1&username=COLORLIGHT10-PlayBox_CLT08153930600&conn_state=connected
		// 参数集合： username  、 conn_state
		try {
			String username = "03ddb4c778bec27a";
			String password = "TG8hTQoTYS8ea1K37jSk6pCwyjxbdYXeC1LrFtseNdD";
			
			OkHttpClient client = new OkHttpClient();
			
			Request request = new Request.Builder()
					.url("http://192.168.51.114:18083/api/v5/nodes")
					.header("Content-Type", "application/json")
					.header("Authorization", Credentials.basic(username, password))
					.build();
			
			Response response = client.newCall(request).execute();
			System.out.println(response.body().string());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}